cmake_minimum_required(VERSION 3.10.0)
project(ASIOStudy)

set_property(GLOBAL PROPERTY USE_FOLDERS ON)
set(CMAKE_CONFIGURATION_TYPES "Debug;Release" CACHE STRING "list of supported configurations." FORCE)

set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG ${PROJECT_SOURCE_DIR}/../bin)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE ${PROJECT_SOURCE_DIR}/../bin)
set(CMAKE_ARCHIEVE_OUTPUT_DIRECTORY_DEBUG ${PROJECT_SOURCE_DIR}/../lib)
set(CMAKE_ARCHIEVE_OUTPUT_DIRECTORY_RELEASE ${PROJECT_SOURCE_DIR}/../lib)

include_directories(${PROJECT_SOURCE_DIR}/../thirdparty/inc/asio)

if(CMAKE_SIZEOF_VOID_P STREQUAL "4")
	message(STATUS x86)
elseif(CMAKE_SIZEOF_VOID_P STREQUAL "8")
	message(STATUS x64)
endif()

message(STATUS ${CMAKE_CXX_COMPILER_ID})
if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
	add_definitions(-D_CRT_SECURE_NO_WARNINGS)
	add_compile_options(/W3 /WX)
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
    add_compile_options(-std=c++11 -Werror)
endif()

macro(group_src_by_dir SRC_LIST)
    foreach(SRC_PATH ${${SRC_LIST}})
        string(REGEX REPLACE "${CMAKE_CURRENT_SOURCE_DIR}/(.*)/.+$" \\1 GROUP_NAME ${SRC_PATH})
        if(NOT SRC_PATH STREQUAL GROUP_NAME)
            string(REPLACE "/" "\\" GROUP_NAME ${GROUP_NAME})
            source_group(${GROUP_NAME} FILES ${SRC_PATH})
        else()
            source_group("" FILES ${SRC_PATH})
        endif()
    endforeach(SRC_PATH)
endmacro(group_src_by_dir)

add_subdirectory(sync_timer)
add_subdirectory(async_timer)
add_subdirectory(async_timer_with_args)
add_subdirectory(async_timer_with_member_func)
add_subdirectory(async_timer_in_multithread)
add_subdirectory(sync_tcp_client)
add_subdirectory(sync_tcp_server)
add_subdirectory(async_tcp_server)
add_subdirectory(sync_udp_client)
add_subdirectory(sync_udp_server)
add_subdirectory(async_udp_server)
add_subdirectory(async_tcp_udp_server)
add_subdirectory(allocation_server)
add_subdirectory(reference_counted)
add_subdirectory(chat_demo)
add_subdirectory(echo_demo)
add_subdirectory(future)
add_subdirectory(reactor)
add_subdirectory(custom_tracking)
add_subdirectory(high_concurrency)
add_subdirectory(connect_stress_test)
if(WIN32)
elseif(UNIX)
    add_subdirectory(deamon)
    add_subdirectory(process_per_connection)
endif()
